ifdef OS
	CHECK_QT = cmd <<< "qtenv2.bat && vcvars64.bat && exit || exit 1"
	PLATFORM_QMAKE = cmd <<< "pushd %cd% && qtenv2.bat && vcvars64.bat && popd && qmake ..\qtbinding\qtbinding_windows.pro && exit || exit 1"
	PLATFORM_MAKE = cmd <<< "vcvars64.bat && nmake && exit || exit 1"
	LIBNAME = standalone/qt/build/release/qtbinding.dll
	EXENAME = kumachan.exe
else
	CHECK_QT = qmake -v
	PLATFORM_QMAKE = qmake ../qtbinding/qtbinding.pro
	PLATFORM_MAKE = $(MAKE)
	LIBNAME = standalone/qt/build/libqtbinding*
	EXENAME = kumachan
endif

default: all

check:
	@echo -e '\033[1mChecking for Qt...\033[0m'
	$(CHECK_QT)
	@echo -e '\033[1mChecking for Go...\033[0m'
	go version

qt:
	@echo -e '\033[1mCompiling CGO Qt Binding...\033[0m'
	cd standalone/qt/build && $(PLATFORM_QMAKE) && $(PLATFORM_MAKE)
	cp -P $(LIBNAME) build/

deps: check qt
	$(NOOP)

interpreter: deps
	@echo -e '\033[1mCompiling the Interpreter...\033[0m'
	go build -o ./build/$(EXENAME) main.go

.PHONY: check qt resources deps interpreter
all: interpreter

